﻿/*************************************************************************
* 计算机名：AA-FA-05
* CLR 版本：4.0.30319.42000
* 命名空间: CustomControls.Controls
* 类    名：TextBoxEx
* 当 前 域：HYRC
* 创 建 人：dailuyu
* 创建时间：2021/6/30 14:37:26
* 描    述：
*  V0.01 2021 初版
*
*  Copyright (c) 2021 aatsr Corporation. All rights reserved.
*  ┌──────────────────────────────────┐
*  │　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*  └──────────────────────────────────┘
***************************************************************************/

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Brush = System.Windows.Media.Brush;
using Color = System.Windows.Media.Color;

namespace CustomControls.Controls
{
    public class TextBoxEx : TextBox
    {
        static TextBoxEx()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(TextBoxEx), new FrameworkPropertyMetadata(typeof(TextBoxEx)));
        }

        public TextBoxEx()
        {
            CommandBindings.Add(new CommandBinding(SearchClickCommand, delegate
            {
                SearchClick?.Invoke(this, null);
            }));
        }

        public static RoutedUICommand SearchClickCommand = new RoutedUICommand(nameof(SearchClickCommand), nameof(SearchClickCommand), typeof(RoutedUICommand));

        public event EventHandler SearchClick;
        public string WaterMark
        {
            get { return (string)GetValue(WaterMarkProperty); }
            set { SetValue(WaterMarkProperty, value); }
        }

        public static readonly DependencyProperty WaterMarkProperty =
            DependencyProperty.Register("WaterMark", typeof(string), typeof(TextBoxEx), new PropertyMetadata(null));


        public ImageSource Icon
        {
            get { return (ImageSource)GetValue(IconProperty); }
            set { SetValue(IconProperty, value); }
        }

        public static readonly DependencyProperty IconProperty =
            DependencyProperty.Register("Icon", typeof(ImageSource), typeof(TextBoxEx), new PropertyMetadata(null));


        public SolidColorBrush MouseOverBorderBrush
        {
            get { return (SolidColorBrush)GetValue(MouseOverBorderBrushProperty); }
            set { SetValue(MouseOverBorderBrushProperty, value); }
        }

        public static readonly DependencyProperty MouseOverBorderBrushProperty =
            DependencyProperty.Register("MouseOverBorderBrush", typeof(SolidColorBrush), typeof(TextBoxEx), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(79, 173, 216))));


        public SolidColorBrush MouseOverBackground
        {
            get { return (SolidColorBrush)GetValue(MouseOverBackgroundProperty); }
            set { SetValue(MouseOverBackgroundProperty, value); }
        }

        public static readonly DependencyProperty MouseOverBackgroundProperty =
            DependencyProperty.Register("MouseOverBackground", typeof(SolidColorBrush), typeof(TextBoxEx), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(106, 103, 90))));


        public CornerRadius CornerRadius
        {
            get { return (CornerRadius)GetValue(CornerRadiusProperty); }
            set { SetValue(CornerRadiusProperty, value); }
        }

        public static readonly DependencyProperty CornerRadiusProperty =
            DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(TextBoxEx), new PropertyMetadata(new CornerRadius(0)));



        public IconDirection IconDirection
        {
            get { return (IconDirection)GetValue(IconDirectionProperty); }
            set { SetValue(IconDirectionProperty, value); }
        }

        public int KeyPress { get; set; }

        public static readonly DependencyProperty IconDirectionProperty =
            DependencyProperty.Register("IconDirection", typeof(IconDirection), typeof(TextBoxEx), new PropertyMetadata(IconDirection.Right));
    }

    public enum IconDirection
    {
        Left,
        Right
    }
}